package com.jekun.helloworld.designmode.composite;

import com.jekun.helloworld.exception.LeafException;
import lombok.extern.slf4j.Slf4j;

/**
 * @author Administrator
 */
@Slf4j
public class Leaf extends Component {
    @Override
    public void add(Component c) throws Exception { //异常处理或错误提示
        throw new Exception("叶子节点没有添加功能");
//        throw new LeafException("叶子节点没有添加功能");
    }

    @Override
    public void remove(Component c) throws Exception { //异常处理或错误提示
        throw new LeafException("叶子节点没有删除功能");
    }

    @Override
    public Component getChild(int i) throws Exception { //异常处理或错误提示
        throw new LeafException("叶子节点没有子节点");
    }

    @Override
    public void operation() {
        //实现代码
        log.info("做点什么");
    }
}
